/*
 * CreepFastForward.java
 *
 * Created on February 24, 2008, 1:11 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package hextd.creep;

import hextd.util.Cache;
import hextd.util.Geometry;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Shape;
import java.awt.Stroke;
import com.usoog.tdcore.gamestate.GameState;

/**
 *
 * @author hylke
 */
public class CreepFastForward extends CreepBaseDirectional {

	public static String type = "ff";
	//
	private Color bodyColor = new Color(100, 150, 200);
	private static String infoText =
			"<h1>FastForward</h1>"
			+ "<p>"
			+ "It's going forward fast. Catch it if you can!<br>"
			+ "</p>";

	@Override
	public void init(GameState gs, HexTDCreepData data) {
		data.health = data.health * 8 / 10;
		super.init(gs, data);
		this.speed = 100 / 1000;        // * 1/1000 segments per tick
		this.speedMax = 100 / 1000;     // * 1/1000 segments per tick
		this.speedMaxBase = 100 / 1000; // * 1/1000 segments per tick
		this.power = 100 / 1000;        // power > speedMax => speed = speedMax
		this.powerBase = 100 / 1000;    // power > speedMax => speed = speedMax
	}

	@Override
	public String getType() {
		return type;
	}

	@Override
	public String getInfoString() {
		return CreepFastForward.infoText
				+ "<p>" + super.getInfoString() + "</p>";
	}

	/** Creates a new instance of CreepFastForward */
	public CreepFastForward() {
		super("Fast Forward");
	}

	@Override
	String getSvgName() {
		return null;
	}

	@Override
	Shape[] generateShapes() {
		Shape[] shapes;
		Cache cache = Cache.getInstance();
		if (cache.hasShapeArr("ESFFShapes" + this.size.letter)) {
			shapes = cache.getShapeArr("ESFFShapes" + this.size.letter);
		} else {
			int frames = 16;
			shapes = new Shape[frames];

			double dr = 2.0 * Math.PI / frames;
			double r = 0;
			for (int i = 0; i < shapes.length; i++) {

				double scale = paintScale * this.size.scaleMod;
				double[][] points = {
					{scale * (-5.5 + 5 * (float) Math.sin(-r)) / 24, +scale * (3.5 + 1.75 * (float) Math.cos(-r)) / 24},
					{scale * (1.5 + 5 * (float) Math.sin(-r)) / 24, +scale * (3.5 + 1.75 * (float) Math.cos(-r)) / 24},
					{scale * (0.0) / 24, 0},
					{scale * (5.5) / 24, 0},
					{scale * (0.0) / 24, 0},
					{scale * (1.5 + 5 * (float) Math.sin(-r)) / 24, -scale * (3.5 + 1.75 * (float) Math.cos(-r)) / 24},
					{scale * (-5.5 + 5 * (float) Math.sin(-r)) / 24, -scale * (3.5 + 1.75 * (float) Math.cos(-r)) / 24}
				};
				shapes[i] = Geometry.coordsToGeneralPath(points, false);
				r += dr;
			}
			cache.putShapeArr("ESFFShapes" + this.size.letter, shapes);
		}
		return shapes;
	}

	@Override
	Stroke generateStroke() {
		return new BasicStroke(2.5f * (float) strokeWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	}

	@Override
	Color generateColor() {
		return this.bodyColor;
	}
}
